﻿using System;
using System.Collections.Generic;
using System.Linq;
using MealBooking.Core.Models.Dishes;
using System.Text;

namespace MealBooking.Core.Models.Meals
{
    public class MealCategory
    {
        public string Id { get; set; }
        public string Name { get; set; }
        public double Price { get; set; }
        public List<DishCategory> DishCategories
        {
            get
            {
                if (DishTemplates != null && DishTemplates.Count != 0)
                {
                    return DishTemplates.Select(t => t.Category).ToList();
                }
                return null;
            }
            set
            {
                value = DishCategories;
            }
        }
        public List<DishTemplate> DishTemplates { get; set; }
        public string Description { get; set; }

        public string Detail()
        {
            if (this.DishTemplates == null || this.DishTemplates.Count == 0)
            {
                return null;
            }
            StringBuilder sb = new StringBuilder();
            this.DishTemplates.ForEach(t => sb.Append(t.Category.Name).Append(" : ").Append(t.DishSum).Append(" "));
            return sb.ToString();
        }
    }
    public class DishTemplate
    {
        public DishCategory Category { get; set; }
        public int DishSum { get; set; }
    }
}